Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve precompiled DX #121

Merged
merged 4 commits into from
Jan 16, 2024
Merged

Improve precompiled DX #121

merged 4 commits into from
Jan 16, 2024

Conversation

mat-hek
Copy link
Member

@mat-hek mat-hek commented Jan 4, 2024

No description provided.

Base automatically changed from fix-release-precompiled to master January 4, 2024 13:43
@mat-hek mat-hek force-pushed the precompiled-dx branch 2 times, most recently from 56c8e1d to 18eda03 Compare January 4, 2024 13:47
@mat-hek mat-hek changed the title Precompiled dx Improve precompiled DX Jan 4, 2024
@mat-hek mat-hek self-assigned this Jan 4, 2024
Comment on lines +143 to +145
require Logger

Logger.error("""
Copy link
Member

@FelonEkonom FelonEkonom Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
require Logger
Logger.error("""
Bundlex.Output.warn("""

Are you sure Logger will work here? Loading a NIF may happen in the compile time

Copy link
Member Author

@mat-hek mat-hek Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm quite sure. I changed it from raise because previously we'd get both error and warning, both via Logger. I think Bundlex.Output.warn would work too, but I'm not sure about other Bundlex.Output functions, so I'd not use it in runtime

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so I checked and in the compilation the bundlex compilation is called first and there we do Application.ensure_all_started https://github.com/membraneframework/bundlex/blob/master/lib/mix/tasks/compile.bundlex.ex#L22 and because we have :logger in extra_applications in mix.exs, the logger should be started at that point. So, it seems that the logger is started before any C code is even compiled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If so, is there any reason to call IO.warn/1 in Bundlex.Output.warn/1 or Mix.shell().info/1 in Bundlex.Output.info/1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why we do this, probably we could use Logger as well ¯\_(ツ)_/¯

Application.get_env(:bundlex, :disable_precompiled_os_deps, [])
|> Keyword.get(:apps, [])
|> Bunch.listify()
is_precompiled_disabled =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is_precompiled_disabled =
precompiled_disabled? =

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention is to use the quotation mark in function names only AFAIK


if native.app in disabled_apps do
if is_precompiled_disabled do
{:error,
"""
is disabled in the application configuration, check the config.exs file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW this error message looks strange. What is disabled in the application configuration?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's concatenated to a prefix in line 90 :P

Comment on lines +52 to +64
```elixir
config :bundlex, :disable_precompiled_os_deps, true
```

Note that this will affect the natives and libs defined in the `bundlex.exs` files of specified
applications only, not in their dependencies.
or for given applications (Mix projects), for example:

```elixir
config :bundlex, :disable_precompiled_os_deps,
apps: [:my_application, :another_application]
```

Note that this will affect the natives and libs defined in the `bundlex.exs` files of specified
applications only, not in their dependencies.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary additional tab

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it the indent breaks in the generated docs for some reason

is_precompiled_disabled =
case Application.get_env(:bundlex, :disable_precompiled_os_deps, false) do
bool when is_boolean(bool) -> bool
[apps: apps] -> native.app in Bunch.listify(apps)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not mentioned in the Bundlex.Project moduledoc, that apps might be also just name of the app, eg. [apps: :my_app]

FelonEkonom

This comment was marked as duplicate.

@FelonEkonom FelonEkonom self-requested a review January 15, 2024 15:17
Copy link
Member

@FelonEkonom FelonEkonom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh, I don't like the fact, that in one place we use Logger and in the another place we use IO, but I understand that there is no option to have an error-like log without nor raising an error neither using Logger

@mat-hek mat-hek merged commit 37867a3 into master Jan 16, 2024
3 checks passed
@mat-hek mat-hek deleted the precompiled-dx branch January 16, 2024 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants